Build a predictive model that answers the question"what sorts of people were more likely to survive?” using passenger data (ie name, age, gender, socio-economic class, etc).
#Toggle code section in below noteImagek
from IPython.display import HTML
HTML('''<script>
code_show=true;
function code_toggle() {
if (code_show){
$('div.input').hide();
document.getElementById('btn_toggle').value="Show Code";
} else {
$('div.input').show();
document.getElementById('btn_toggle').value="Hide Code";
}
code_show = !code_show
}
$( document ).ready(code_toggle);
</script>
<form action="javascript:code_toggle()"><input style = "float:right" type="submit" id="btn_toggle">''')
#Importing libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
from wordcloud import WordCloud
from sklearn.preprocessing import LabelEncoder
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
from sklearn.metrics import confusion_matrix
from IPython.display import Image
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import KFold
from sklearn.model_selection import StratifiedKFold
from sklearn.model_selection import cross_val_score
from sklearn.svm import SVC
from sklearn.tree import DecisionTreeClassifier
from xgboost import XGBClassifier
from sklearn.neighbors import KNeighborsClassifier
# Setting up visualisations
sns.set_style(style='white')
sns.set(rc={
'figure.figsize':(12,7),
'axes.facecolor': 'white',
'axes.grid': True,
'grid.color': '.9',
'axes.linewidth': 1.0,
'grid.linestyle': u'-'},
font_scale=1.5)
custom_colors = ["#3498db", "#95a5a6","#34495e", "#2ecc71", "#e74c3c"]
sns.set_palette(custom_colors)
Image("Titanic_3.jpg", width = 700, height=50)